package com.open4cn.simulator.connect.tcp.handler;

import cn.hutool.json.JSONUtil;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description 打印解密之后的输入(读)日志
 * @Email yinxiaopeng@zj.tech
 * @date 2022-04-05 21:54
 */
@ChannelHandler.Sharable
public class ReadLogAfterDecodeHandler extends ChannelInboundHandlerAdapter {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    private String device;

    public ReadLogAfterDecodeHandler(String device) {
        this.device = device;
    }

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        logger.info("当前{}设备接收到解密消息=>{}", device, JSONUtil.toJsonStr(msg));
        super.channelRead(ctx, msg);
    }
}
